# 57 None
"""
演示特殊字面量：None
"""

# # 无return语句的函数返回值
# def say_hi():
#     print("你好呀")
#
#
# result = say_hi()
# print(f"无返回值函数，返回的内容是：{result}")
# print(f"无返回值函数，返回的内容类型是：{type(result)}")

# 主动返回None的函数
# def say_hi2():
#     print("你好呀")
#     return None
#
#
# result = say_hi2()
# print(f"无返回值函数，返回的内容是：{result}")
# print(f"无返回值函数，返回的内容类型是：{type(result)}")


# # None用于if判断
# def check_age(age):
#     if age > 18:
#         return "SUCCESS"
#     else:
#         return None
#
#
# result = check_age(19)
# if result:
#     # 进入if表示result是None值 也就是False
#     print("未成年，不可以进入")
#
# # None用于声明无初始内容的变量
# name = None

# 58 函数说明文档

# def add(x, y):
#     """
#     add函数可以接受两个参数，进行两数相加的功能
#     :param x:参数x表示其中的一个数字
#     :param y:参数y表示其中的另外一个数字
#     :return:返回值是2数相加的结果
#     """
#     result = x + y
#     print(result)
#     return result
#
#
# add(5, 6)

# 59 函数的嵌套调用
# def fun_a():
#     print("1111111111")
#
#
# def fun_b():
#     print("2222222222")
#     fun_a()
#     print("333333333333")
#
#
# fun_b()

# 60 变量在函数中的作用
# def b_test_a():
#     num = 100
#     print(num)
#
#
# b_test_a()
# # print(num)

# num = 100
#
#
# def a_test():
#     print(f"test_a:{num}")
#
#
# def b_test():
#     print(f"test_b:{num}")
#
#
# a_test()
# b_test()
# print(num)

# num = 100
#
#
# def a_test():
#     print(f"test_a:{num}")
#
#
# def b_test():
#     global num
#     num = 500
#     print(f"test_b:{num}")
#
#
# a_test()
# b_test()
# print(num)

# 61 综合案例
# money = 5000000
# name = input("请输入你的姓名：")
#
#
# def query(show_header):
#     if show_header:
#         print("------------查询余额-------------")
#     print(f"{name},您好，您的余额剩余{money}元")
#
#
# def save(num):
#     global money
#     money += num
#     print('------------存款--------------')
#     print(f"{name},您好，您存款{num}元成功")
#
#     query(False)
#
#
# def get_money(num):
#     global money
#     money -= num
#     print("-----------取款------------")
#     print(f"{name},您好，您取款{num}元成功")
#     query(False)
#
#
# def main():
#     print("-------------主菜单------------")
#     print(f"{name}，您好，欢迎来到黑马银行ATM。请选择操作：")
#     print("查询余额\t[输入1]")
#     print("存款\t\t[输入2]")
#     print("取款\t\t[输入3]")  # 通过\t制表符对齐输出
#     print("退出\t\t[输入4]")
#     return input("请输入您的选择：")
#
#
# while True:
#     keyboard_input = main()
#     if keyboard_input == "1":
#         query(True)
#         continue  # 通过continue继续下一次循环，一进来就是回到了主菜单
#     elif keyboard_input == "2":
#         num = int(input("您想要存多少钱？请输入："))
#         save(num)
#         continue
#     elif keyboard_input == "3":
#         num = int(input("您想要取多少钱？请输入："))
#         get_money(num)
#         continue
#     else:
#         print("程序退出啦")
#         break  # 通过break退出循环

# 62 数据容器


# 63 list
# my_list = ['wenxiaojian', 'duchenxiao', 'qupengfei']
# print(my_list)
# print(type(my_list))
#
# my_list = ['wenxiaojian', 666, True]
# print(my_list)
# print(type(my_list))
#
# my_list = [[1, 2, 3], [4, 5, 6]]
# print(my_list)
# print(type(my_list))

# 64 列表的下标索引
# my_list = ['wenxiaojian', 'duchenxiao', 'qupengfei']
# print(my_list[0])
# print(my_list[1])
# print(my_list[2])
#
# print(my_list[-1])
# print(my_list[-2])
# print(my_list[-3])
#
# my_list = [[1, 2, 3], [4, 5, 6]]
# print(my_list[1][1])

# 65 列表的常用操作方法
# mylist = ["itcast", "itheima", "python"]
# # 1.1 查找某元素在列表内的下标索引
# index = mylist.index("itheima")
# print(f"itheima在列表中的下标索引值是：{index}")
# # 1.2如果被查找的元素不存在，会报错
# # index = mylist.index("hello")
# # print(f"hello在列表中的下标索引值是：{index}")
#
# # 2. 修改特定下标索引的值
# mylist[0] = "传智教育"
# print(f"列表被修改元素值后，结果是：{mylist}")
# # 3. 在指定下标位置插入新元素
# mylist.insert(1, "best")
# print(f"列表插入元素后，结果是：{mylist}")
# # 4. 在列表的尾部追加```单个```新元素
# mylist.append("黑马程序员")
# print(f"列表在追加了元素后，结果是：{mylist}")
# # 5. 在列表的尾部追加```一批```新元素
# mylist2 = [1, 2, 3]
# mylist.extend(mylist2)
# print(f"列表在追加了一个新的列表后，结果是：{mylist}")
# # 6. 删除指定下标索引的元素（2种方式）
# mylist = ["itcast", "itheima", "python"]
#
# # 6.1 方式1：del 列表[下标]
# del mylist[2]
# print(f"列表删除元素后结果是：{mylist}")
# # 6.2 方式2：列表.pop(下标)
# mylist = ["itcast", "itheima", "python"]
# element = mylist.pop(2)
# print(f"通过pop方法取出元素后列表内容：{mylist}, 取出的元素是：{element}")
# # 7. 删除某元素在列表中的第一个匹配项
# mylist = ["itcast", "itheima", "itcast", "itheima", "python"]
# mylist.remove("itheima")
# print(f"通过remove方法移除元素后，列表的结果是：{mylist}")
#
# # 8. 清空列表
# mylist.clear()
# print(f"列表被清空了，结果是：{mylist}")
# # 9. 统计列表内某元素的数量
# mylist = ["itcast", "itheima", "itcast", "itheima", "python"]
# count = mylist.count("itheima")
# print(f"列表中itheima的数量是：{count}")
#
# # 10. 统计列表中全部的元素数量
# mylist = ["itcast", "itheima", "itcast", "itheima", "python"]
# count = len(mylist)
# print(f"列表的元素数量总共有：{count}个")

# 66 练习
# num = [21, 25, 21, 23, 22, 20]
# num.append(31)
# print(num)
#
# num.extend([29, 33, 30])
# print(num)
#
# take = num.pop(0)
# print(take)
#
# take = num.pop(-1)
# print(take)
#
# index = num.index(31)
# print(num)
# print(index)

# 67 列表的循环遍历
# mylist = ['wenxiaojian', 'hanlei', 'yangyinjie']
#
#
# def list_while_func():
#     index = 0
#     while index < len(mylist):
#         element = mylist[index]
#         print(element)
#         index += 1
#
#
# list_while_func()
#
#
# def list_for_func():
#     mylist1 = ['wenxiaojian', 'hanlei', 'yangyinjie']
#     for element in mylist1:
#         print(element)
#
# list_for_func()

# 68 元组
# 定义元组
# t1 = (1, "Hello", True)
# t2 = ()
# t3 = tuple()
# print(f"t1的类型是：{type(t1)}, 内容是：{t1}")
# print(f"t2的类型是：{type(t2)}, 内容是：{t2}")
# print(f"t3的类型是：{type(t3)}, 内容是：{t3}")
#
# # 定义单个元素的元素
# t4 = ("hello",)
# print(f"t4的类型是：{type(t4)}, t4的内容是：{t4}")
# # 元组的嵌套
# t5 = ((1, 2, 3), (4, 5, 6))
# print(f"t5的类型是：{type(t5)}, 内容是：{t5}")
#
# # 下标索引去取出内容
# num = t5[1][2]
# print(f"从嵌套元组中取出的数据是：{num}")
#
# # 元组的操作：index查找方法
# t6 = ("传智教育", "黑马程序员", "Python")
# index = t6.index("黑马程序员")
# print(f"在元组t6中查找黑马程序员，的下标是：{index}")
# # 元组的操作：count统计方法
# t8 = ("传智教育", "黑马程序员", "黑马程序员", "黑马程序员", "Python")
# num = len(t8)
# print(f"t8元组中的元素有：{num}个")
# # 元组的遍历：while
# index = 0
# while index < len(t8):
#     print(f"元组的元素有：{t8[index]}")
#     # 至关重要
#     index += 1
#
# # 元组的遍历：for
# for element in t8:
#     print(f"2元组的元素有：{element}")
#
# # 修改元组内容
# # t8[0] = "itcast"
#
# # 定义一个元组
# t9 = (1, 2, ["itheima", "itcast"])
# print(f"t9的内容是：{t9}")
# t9[2][0] = "黑马程序员"
# t9[2][1] = "传智教育"
# print(f"t9的内容是：{t9}")

# t1 = ('wenxiaojian', 11, ['football', 'music'])
# index = t1.index(11)
# print(index)
#
# index = t1.index('wenxiaojian')
# print(index)
#
# del t1[2][1]
# print(t1)
#
# t1[2].append('coding')
# print(t1)
